package com.xc.hotelmgr.datahandlermt.controller;

import com.xc.hotelmgr.datahandlermt.pojo.mq.DelRp;
import com.xc.hotelmgr.datahandlermt.result.MtResult;
import com.xc.hotelmgr.datahandlermt.service.mt.RpService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rateplan")
@RequiredArgsConstructor
public class RpToMQController {

    private final RpService rpService;

    /**
     * 删除价格价格（前端调用），前端删除自定义价格计划时调用
     * 将要删除的店铺分组下的酒店价格计划，放入delete_rp_#{appkey}队列
     * @param delRp
     * @return
     */
    @RequestMapping(value = "/del", method = RequestMethod.POST)
    public MtResult delRp(@RequestBody DelRp delRp) {
        Integer storeId = delRp.getStoreId();
        Integer groupId = delRp.getGroupId();
        Integer opOurRateplanId = delRp.getOpOurRateplanId();
        boolean result = rpService.delRp(storeId, groupId, opOurRateplanId);
        if(result) {
            return new MtResult(0, "succ");
        }
        return new MtResult(-1, "fail");
    }
}
